package com.example.springboot.controller.bookstore;

import com.example.springboot.bean.ProductRecord;
import com.example.springboot.dao.ProductRecordDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by tang on 2018/3/8.
 */
@RestController
@RequestMapping("/productRecord")
public class ProductRecordController {

    @Autowired
    private ProductRecordDao productRecordDao;

    @RequestMapping("/findAll")
    public ModelAndView findAlll() {
        ModelAndView mv = new ModelAndView();

        List<ProductRecord> productRecordList = productRecordDao.findAll();
        mv.setViewName("bookstore/book_list");
        mv.addObject("bookList", productRecordList);

        return mv;
    }

}
